﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace CusCheckedListBox
{
    public class CoolItemCollection:IList,ICollection,IEnumerable
    {
        #region Fields
        private CoolCheckedListBox _owner;
        #endregion

        public CoolItemCollection(CoolCheckedListBox owner)
        {
            this._owner = owner;
        }
        internal CoolCheckedListBox Owner
        {
            get { return _owner; }
        }


        #region IEnumerable 成员

        public IEnumerator GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region ICollection 成员

        public void CopyTo(Array array, int index)
        {
            CopyTo((CoolItem[])array, index);
        }

        public int Count
        {
            get { return this.Owner.Items.Count; }
        }

        public bool IsSynchronized
        {
            get { return false; }
        }

        public object SyncRoot
        {
            get { return this; }
        }

        #endregion

        #region IList 成员

        public int Add(object value)
        {
            if (!(value is CoolItem))
            {
                throw new ArgumentException();
            }
            return this.Add(value as CoolItem);
        }

        public void Clear()
        {
            this.Clear();
        }

        public bool Contains(object value)
        {
            return Contains(value as CoolItem);
        }

        public int IndexOf(object value)
        {
            return this.IndexOf(value as CoolItem);
        }

        public void Insert(int index, object value)
        {
            this.Insert(index, value as CoolItem);
        }

        public bool IsFixedSize
        {
            get { return false; }
        }

        public bool IsReadOnly
        {
            get { return IsReadOnly; }
        }

        public void Remove(object value)
        {
            this.Remove(value as CoolItem);
        }

        public void RemoveAt(int index)
        {
            this.RemoveAt(index);
        }

        public object this[int index]
        {
            get { return this[index] as CoolItem; }
            set
            {
                if (!(value is CoolItem))
                {
                    throw new ArgumentException();
                }
                this[index] = value;
            }
        }

        #endregion
    }
}
